// 获取用户登陆状态
DetLogin()

$(function () {
    ImporInfor()
    $.ajax({
        url:host + '/myhome/shop/getMyAuthenticateStatus',
        data: Infornation,
        success:function (data) {
            if(data.success){

                var data = data.data,
                    userName = Cookie.getCookie()['username'];
                    if(userName){
                        $('#username').text(decodeURI(userName).trim()).removeClass('hidden');
                    }
                if(data.data){
                    $('#authentication').html('未认证').removeClass('hidden')
                    return;
                }
                if(data.auditStatus!==2){
                    if(data.authenticationStatus !== 2){
                        $('#authentication').html('未认证').removeClass('hidden')
                    }else {
                        $('#authentication').html('个人已认证').removeClass('hidden')
                    }
                   return;
                }else if(data.authenticationStatus === 1) {
                    $('#authentication').html('个人已认证').removeClass('hidden')
                }else {
                    $('#authentication').html('企业已认证').removeClass('hidden')
                }
            }
        }
    })
})
var num = '';
$('#middle li').on('click',function(){
	num = $(this).index();
//	console.log($(this).index())
	if(num == 0){
//		alert(123)
		window.location.href = 'order.html?purchase=true'
	}else if(num == 1){
		//供应订单
		window.location.href = 'order.html?supply=true'
	}else if(num == 2){
		//采购消息
		window.location.href = 'message.html?purchase=true'
	}else if(num == 3){
		//供应消息
		window.location.href = 'message.html?supply=true'
	}else if(num == 4){
		//我的账户
		window.location.href = 'myCollect.html'
	}else if(num == 5){
		//修改密码
		window.location.href = 'myShop.html'
	}else if(num == 6){
        window.location.href = 'authentication.html?personal=true'
// 		//实名认证
// //		window.location.href = 'realName.html'
// 		//这里需要验证实名认证信息
// 		realName();
	}else if(num == 7){
        window.location.href = 'authentication.html'
    }else if(num == 8){
        window.location.href = 'feedBack.html'
    }
})
//点击退出要跳回登陆页面  和  清空cookies
$('#exitUser div').on('click',function(){
	console.log(1);
//	Cookie.removeCookie();
	console.log(Cookie.getCookie());
//	DelCookie('userName')
	for(var i in Cookie.getCookie()){
		DelCookie(i)
	}
	window.location.href = 'login.html'
	
})

function DelCookie(name) {
  var exp = new Date();
  exp.setTime(exp.getTime() + (-1 * 24 * 60 * 60 * 1000));
  var cval = GetCookieValue(name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function GetCookieValue(name) {
  var cookieValue = null;
  if (document.cookie && document.cookie != '') {
 var cookies = document.cookie.split(';');
 for (var i = 0; i < cookies.length; i++) {
   var cookie = jQuery.trim(cookies[i]);
   //PYYH=USERNAME=steven&PASSWORD=111111&UserID=1&UserType=1
   if (cookie.substring(0, name.length + 1) == (name + '=')) {
 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
 //USERNAME=steven&PASSWORD=111111&UserID=1&UserType=1
 break;
   }
 }
  }
  return cookieValue;
} 
function exit() {
  DelCookie("PYYH");
  window.location.replace("http://localhost:7877/index.aspx");
}
//realName实名认证

// setting click
$(function () {
    $('.header-tab').on('click', function (e) {
        var widthH = $(this).width(),
            current = e.originalEvent.x || e.originalEvent.layerX || 0; ;
        console.log(current)
        console.log(e)
        if(current >= widthH * 0.85){
            window.location.href = 'myAccount.html'
        }
    })
})